package com.example.carrierapp.viewmodel.itemmodel

import android.databinding.BaseObservable
import android.graphics.Color
import android.view.View
import com.example.carrierapp.config.mStartActivity
import com.example.carrierapp.ui.main.waybill.details.WaybillDetailsActivity
import com.example.carrierapp.util.ActivityUtil

class ItemWaybillModel : BaseObservable() {

    var lineCode = "" //线路编码及资源编码

    var shipmentNumber = "" //发货编码及调度编码

    var waybillCode = "" //运单编码

    var driverName = "" //司机名称

    var driverPhone = "" //司机手机号

    var carNumber = "" //运输车牌

    var schedulingNum = 0f // 调度量

    var loadingNum = 0f // 装货量

    var unloadingNum = 0f // 卸货量

    var billState = 0 //运单状态 1 = 待装车 2 = 运输中 3 = 已送达 4 = 已删除 = ['1', '2', '3', '-1']

    var billStateName = "" // 运单状态名称

    var productId = 0//产品Id

    var proName = "" //货物名称

    var proPicPath = "" //货物图片路径

    var startAddress = "" //装货地

    var startAddressDtl = "" //装货地详细地址

    var endAddress = "" //卸货地

    var endAddressDtl = "" //卸货地详细地址

    var carrierSettlementType = 0// 承运商计价单位 1 = 元/吨 2 = 元/车 3 = 元/吨/公里 = ['1', '2', '3']

    var settlementTypeName = "" // 承运商计价单位名称

    var carrierSettlState = 0// 承运商结算状态 1 = 不结算 2 = 未结算 3 = 已提交申请 4 = 已结算

    var carrierId = 0// 承运人ID

    var shipperName = "" //托运人名称

    var showUpdate = false
        get() = if (billState == 1 or 2) true else carrierSettlState < 3

    var carText = ""
        get() = "$driverName | $carNumber | $driverPhone"

    var proText = ""
        get() = "$proName | ${when (billState) {
            1 -> schedulingNum
            2 -> loadingNum
            else -> unloadingNum
        }
        }吨"

    var id = 0

    fun toDetails(view: View) {
        view.context.mStartActivity(WaybillDetailsActivity::class.java, Pair("id", id), Pair("state", billState))
    }

    var statusColor = 0
        get() = when (billState) {
            1 -> Color.parseColor("#FF8D1E")
            2 -> Color.parseColor("#FF6C40")
            else -> Color.parseColor("#999999")
        }
}